package edu.ucla.wanda.db;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

public class WandaSensorSpec {
	// required parameters
	private String type, unit;
	
	// optional parameters
	private String id, model, manufacturer, spec;
	
	public WandaSensorSpec(JsonElement element)
	{
		JsonObject object = element.getAsJsonObject();
		
		// required parameters
		if(object.has("Type"))
		{
			type = object.getAsJsonPrimitive("Type").getAsString();
		}
		
		if(object.has("Unit"))
		{
			unit = object.getAsJsonPrimitive("Unit").getAsString();
		}
		
		// optional parameters
		if(object.has("Id"))
		{
			id = object.getAsJsonPrimitive("Id").getAsString();
		}
		
		if(object.has("Model"))
		{
			model = object.getAsJsonPrimitive("Model").getAsString();
		}
		
		if(object.has("Manufacturer"))
		{
			manufacturer = object.getAsJsonPrimitive("Manufacturer").getAsString();
		}
		
		if(object.has("Spec"))
		{
			spec = object.getAsJsonPrimitive("Spec").getAsString();
		}
	}
	
	public WandaSensorSpec(String type, String id, String unit)
	{
		this.type = type;
		this.id = id;
		this.unit = unit;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		if(null != type)
		{
			return type;
		}
		
		return "N/A";
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		if(null != id)
		{
			return id;
		}
		
		return "N/A";
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the unit
	 */
	public String getUnit() {
		if(null != unit)
		{
			return unit;
		}
		
		return "N/A";
	}

	/**
	 * @param unit the unit to set
	 */
	public void setUnit(String unit) {
		this.unit = unit;
	}

	/**
	 * @return the model
	 */
	public String getModel() {
		if(null != model)
		{
			return model;
		}
		
		return "N/A";
	}

	/**
	 * @param model the model to set
	 */
	public void setModel(String model) {
		this.model = model;
	}

	/**
	 * @return the manufacturer
	 */
	public String getManufacturer() {
		if(null != manufacturer)
		{
			return manufacturer;
		}
		
		return "N/A";
	}

	/**
	 * @param manufacturer the manufacturer to set
	 */
	public void setManufacturer(String manufacturer) {
		this.manufacturer = manufacturer;
	}

	/**
	 * @return the spec
	 */
	public String getSpec() {
		if(null != spec)
		{
			return spec;
		}
		
		return "N/A";
	}

	/**
	 * @param spec the spec to set
	 */
	public void setSpec(String spec) {
		this.spec = spec;
	}

}
